﻿<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <!--<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />-->
        <title>用户通知</title>
        <link href="__PUBLIC__/js/themes/default/easy_ui.css" rel="stylesheet" type="text/css" />
        <link href="__PUBLIC__/js/themes/icon.css" rel="stylesheet" type="text/css" />
        <link href="__PUBLIC__/css/demo.css" rel="stylesheet" type="text/css" />
        <script src="__PUBLIC__/js/jquery-1.8.0.min.js" type="text/javascript"></script>
        <script src="__PUBLIC__/js/jquery.easyui.min.js" type="text/javascript"></script>
        <script src="__PUBLIC__/js/jquery.form.js" type="text/javascript"></script>
        <script charset="utf-8" src="__PUBLIC__/editor/kindeditor.js"></script>
        <script charset="utf-8" src="__PUBLIC__/editor/lang/zh_CN.js"></script>
        <style>
            /*file容器样式*/
            a.files{ margin-left: 15px;  width:52px; height:22px; overflow:hidden; display:block; border:1px solid #d7d7d7; background:url(/Public/images/upfile_bg.gif) left top no-repeat;text-decoration:none; }
            /*file设为透明，并覆盖整个触发面*/
            a.files input{ margin-left:-270px; font-size:24px; cursor:pointer; filter:alpha(opacity=0); opacity:0; }
            /*取消点击时的虚线框*/
            a.files, a.files input{ outline:none;/*ff*/hide-focus:expression(this.hideFocus=true);/*ie*/ }
            .audioBox {
                position: relative;
                width: 80px;
                height: 80px;
                background-color: #e4e4e4;
                cursor: pointer;
            }
            .audioBox .audioIconWrp {
                position: absolute;
                top: 50%;
                left: 50%;
                margin: -16px 0 0 -16px;
                width: 32px;
                height: 32px;
            }
            .audioBox .audioIcon {
                background: url("/Public/images/media_z.png") 0 0 no-repeat;
                width: 32px;
                height: 32px;
                vertical-align: middle;
                display: inline-block;
            }
            .audioBox .audioIconGif {
                background: transparent url(/Public/images/icon_audio_gray_s1e7c60.gif) no-repeat 0 0;
                width: 32px;
                height: 32px;
                vertical-align: middle;
                display: inline-block;
                display: none;
            }
            .wxAudioPlaying .audioBox .audioIconGif {
                display: block;
            }
            .wxAudioPlaying .audioBox .audioIcon {
                display:none;
            }
            .input240
            {
                width: 580px;
                height: 22px;
                line-height: 22px;
                border: 1px solid #95B8E7;
                margin-left: 20px;
            }
            .input242
            {
                width: 580px;
                height: 22px;
                line-height: 22px;
                border: 1px solid #95B8E7;
            }
            .input241
            {
                width: 550px;
                height: 22px;
                line-height: 22px;
                border: 1px solid #95B8E7;
                margin-left: 20px;
            }
            .txtRemark
            {
                width: 580px;
                border: 1px solid #95B8E7;
                margin-left: 20px;
                height: 75px;
            }
            .clj
            {
                height: 40px;
                margin-top: 10px;
            }
            .clj a
            {
                font-size: 10pt;
            }
            #tb2{display:none; background:#FFFFFF;border-top: 4px #E0ECFF solid;width: 860px;height: 352px;}
            #tb3{display:none; background:#FFFFFF;border-top: 4px #E0ECFF solid;width: 860px;height: 352px;}
            .right_div{
                float: right;width: 58%;border: 1px #E0ECFF solid;height: 350px;margin-top: 10px;
            }
            .moreright_div{
                float: right;width: 58%;border: 1px #E0ECFF solid;height: 350px;margin-top: 10px;margin-bottom: 20px;
            }
            .left_div{
                float: left;width: 40%;border: 1px #E0ECFF solid;height: 350px;margin-top: 10px;
            }
            .moreleft_div{
                float: left;width: 40%;border: 1px #E0ECFF solid;height: 350px;margin-top: 10px;
            }
            .summary{
                display: none;
            }
            .sourceLink{
                display: none;
            }
            .mpnewsSourceLink{
                display: none;
            }
            #backMessage{
                color: #ccc;
            }
            a:link { 
                text-decoration:none; 
                color: blue;
            } 
            a:visited {  
                text-decoration:none; 
            } 
            a:hover { 
                text-decoration:underline; 
            } 
            a:active {  
                text-decoration:none; 
            } 
            .text1{
                color: #333;
            }
            #coverImage{
                width: 70%; height: 70%;margin: 20px;text-align:center;font-size: 20px;background-color: #ccc;
            }
            #coverImagemore1{
                width: 80%; height: 300px;margin-left: 30px;margin-top: 10px;margin-bottom: 5px;text-align:center;font-size: 20px;background-color: #ccc;
            }
            #bgcolor{
                //#E0ECFF
                width: 100%;height: 60%;background-color: #E0ECFF;display: none;
            }
            #testMessageGrid1{
                margin: 10px;width: 96%;
            }
            #testMessageGrid2{
                margin: 10px;width: 96%;height: 286px;
            }
            /*            .testMessageGrid1{
                            width: 100%;height: 100%;
                        }*/
            .imagemore{
                width: 80%; height: 79%;margin-left: 30px;margin-top: 10px;margin-bottom: 5px;text-align:center;line-height: 200px;font-size: 20px;background-color: #ccc;
            }
            #div{
                margin-top: 60px;border: 1px #E0ECFF solid;
            }
            #div1{
                margin-top: 60px;border: 1px #E0ECFF solid;
            }
            .extendTable{
                margin: 10px;width: 96%;height: 286px;
            }
            //以下是单图文显示框的效果by rocke
            .mpnews {
                width:300px;
                text-align:center;
                /*border-top:1px solid #CCC;*/
                border-color:#CCC;
            }
            .mpnews_bag {
                margin:10px;
            }
            .mpnews_title {
                font-size:16px;
                font-weight:bolder;
                color:#666;
                text-align:left;
            }
            .mulmps_content {
                width:290px;
                font-size:14px;
                color:#666;
                text-align:left;
            }
            //以下是多图文的显示效果by rocke
            .mulmps {
                width:300px;
                text-align:center;
                border:1px solid #CCC;
            }
            .mulmps_head {
                width:270px;
                height:235px;
                text-align:center;
                margin:10px;
            }
            .mulmps_time {
                font-size:14px;
                color:#666;
                text-align:left;
            }
            .mulmps_head_img {
                margin-top:0px;
            }
            .mulmps_head_txt {
                height:40px;
                width:280px;
                text-align:left;
                background-color:#666;
                opacity: 0.5;
                color:#FFF;
                font-size:14px;
            }
            .mulmps_tr{
                border-top:1px solid #CCC;
            }
            .mulmps_child {
                width:280px;
                height:120px;
            }
            .mulmps_child_txt {
                width:170px;
                height:40px;
                font-size:14px;
                color:#666;
                text-align:left;
            }

        </style>

    </head>
    <body class="easyui-layout">
        <div data-options="region:'center',title:'通知'"> 
            <div id="tt" class="easyui-tabs" style="width: 700px; height: 500px;">
                <div title="新建列表通知" style="padding: 20px;">
                    <table>
                        <tr>
                            <td colspan="2">
                                标题
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <input type="text" id="txtNoticTitle" class="easyui-validatebox input242">
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                正文
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <textarea id="txtArea" style="width:662px;height:631px;">{$vo.HtmlContent}</textarea>
                            </td>
                        </tr>
                    </table></br>
                    <a id="btnSave" href="javascript:void(0)"  class="easyui-linkbutton" onclick="SaveHtml()" data-options="iconCls:'icon-ok'">
                        保存</a>

                </div>
                <div title="新建群发消息" style="padding: 20px;">
                    群发对象<select id="SendType" class="easyui-combobox" data-options='"panelHeight":"auto", onSelect: function(rec){ if(rec.value=="1"){ $("#spanGroup").css("display", "inline")}else($("#spanGroup").css("display", "none"))}'
                                name="SendType" style="width: 100px;">
                        <option value="2">全部用户</option>
                        <option value="1">按分组选择</option>
                    </select>
                    <span style="display: none" id="spanGroup">
                        <select id="userGroup" class="easyui-combobox" data-options='"panelHeight":"auto"'
                                name="userGroup" style="width: 100px">
                        </select>
                    </span>
                    <br />
                    <br />
                    <div id="message" class="easyui-tabs"  style="white-space: 600px; height: 300px">
                        <div title="文字" style="padding: 20px;">
                            <textarea id="txtMessage" name="txtMessage" style="width: 99%; height: 90%"></textarea>
                        </div>
                        <div title="图片" id="dimg" style="padding: 20px;">
                        </div>
                        <div title="语音" id="dvoice" style="padding: 20px;">
                        </div>  
                        <div title="视频" id="dvideo" style="padding: 20px;">
                            <video  src="http://video.store.qq.com/vweixinp.tc.qq.com/1007_a70eb791ed774ca68c5fee8af3b8ca74.f10.mp4?vkey=E57F3DAEE89FC5DA575CD205EB135525835E70BD0E0B70B46C705A2211BC1811BF6C189BFC331EFE&sha=0" autoplay="autoplay" height="200px"  controls="controls">
                            </video>
                            <video  src="/Uploads/Videos/2014-07-09/1.mp4" autoplay="autoplay" height="200px"  controls="controls">
                            </video>
                            <video  src="/Uploads/Videos/2014-07-09/2.mp4" autoplay="autoplay" height="200px"  controls="controls">
                            </video>
                            <video  src="/Uploads/Videos/2014-07-09/3.mp4" autoplay="autoplay" height="200px"  controls="controls">
                            </video>
                        </div>
                        <div title="图文消息" id="mpnews" style="padding: 20px;">
                        </div>
                    </div>
                    <br />
                    <br />
                    为保障用户体验，微信公众平台严禁恶意营销以及诱导分享朋友圈，<br />严禁发布色情低俗、暴力血腥、政治谣言等各类违反法律法规及相关<br />政策规定的信息。一旦发现，我们将严厉打击和处理。<br />   <br />
                    <a id="btnSend" href="javascript:void(0)"  class="easyui-linkbutton" data-options="iconCls:'icon-ok'">
                        群发</a>
                </div>
                <div title="列表通知" data-options="closable:false" style="overflow: auto; padding: 20px;">
                    <table class="easyui-datagrid" id="tbNoticGrid" singleselect="true">  
                    </table>
                </div>
            </div>
        </div>
        <!--imagePanal-->
        <div id="imagePanel">
            <table class="easyui-datagrid" id="tbGrid"  singleselect="true">
            </table>
        </div>
        <div id="tb">
            <form id="formImg" name="formImg" enctype="multipart/form-data">
                <a href="javascript:;" class="files"><input type='file' name='imageFile' id='imageFile' onchange="FileSelectEve($('#formImg'), $('#tbGrid'), 'image')"></a>
            </form>
        </div>

        <!--voicePanel-->
        <div id="voicePanel">
            <table class="easyui-datagrid" id="voiceGrid"  singleselect="true">
            </table>
        </div>
        <div id="voiceTool">
            <form id="formVoice" name="formVoice" enctype="multipart/form-data">
                <a href="javascript:;" class="files"><input type='file' name='voiceFile' id='voiceFile' onchange="FileSelectEve($('#formVoice'), $('#voiceGrid'), 'voice')"></a>
            </form>
        </div>
        <!--videoPanel-->
        <div id="videoPanel">
            <table>
                <tr>
                    <td colspan="2">
                        <span style=" margin-left: 20px;">视频</span>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="text" id="txtUrl" class="easyui-validatebox input240" data-options="required:true,missingMessage:'必填'">
                    </td>
                    <td>
                        <form id="formVideo" name="formVideo" enctype="multipart/form-data">
                            <a href="javascript:;" class="files"><input type='file' name='videoFile' id='videoFile' onchange="VideoFileSelectEve()"></a>
                        </form>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <span style=" margin-left: 20px">标题</span>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="text" id="txtTitle" class="easyui-validatebox input240" data-options="required:true,missingMessage:'必填'">    
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <span style=" margin-left: 20px">简介(选填)</span> 
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <textarea id="txtSummary" name="txtSummary" class="txtRemark"></textarea>
                    </td>
                </tr>
            </table>
            <a id="btnSave" href="javascript:void(0)" onclick="VideoInfoSave()" style="  margin-left: 20px"  class="easyui-linkbutton" data-options="iconCls:'icon-save'">
                保存</a></br></br></br>
            <table class="easyui-datagrid" id="videoGrid"  singleselect="true"></table>
        </div>
        <!--graphicPanel,图文消息-->
        <div id="graphicPanel">
            <div class="clj">   
                <div id="message1" class="easyui-tabs"  style="white-space: 600px; height: 40px">
                    <div title="图文列表" id="backMessage" style="padding: 20px;">
                    </div>  
                    <div title="单图文消息" id="singleMessage" style="padding: 20px;">
                    </div>
                    <div title="多图文消息" id="moreMessage" style="padding: 20px;">
                    </div>
                </div>
                <div id="tb1">
                    <table class="easyui-datagrid" id="graphicGrid" singleselect="true"> </table>
                </div>
                <div id="tb2">
                    <div class="right_div">
                        <table id="testMessageGrid1">

                            <tr>
                                <td class="clomns" >
                                    标题：<input name="graphictitle" id="graphictitle" style="width:80%;height: 18px;"/>  
                                </td>
                            </tr>

                            <tr>
                                <td class="clomns">
                                    作者：<input name="graphicauthor" id="graphicauthor" style="width:80%;height: 18px;"/> 
                                </td>
                            </tr>

                            <tr class="rows">
                                <td class="clomns" >
                                    <form id="formGraphic" name="formGraphic">
                                        封面：<input type='file' name='graphicFile' id='graphicFile' onchange="GraphicFileSelectEve()" style="width:81%;height: 18px;"/>
                                    </form>
                                </td>
                            </tr>
                            <tr class="rows">
                                <td  class="text1">
                                    <input type="checkbox" id="ifshow" name="ifshow"  /> 封面显示在正文中
                                </td>
                            </tr>

                            <tr class="rows">
                                <td class="clomns" >
                                    <a href="#" class="addSummary" onclick="showSummary()">添加摘要</a>
                                </td>
                            </tr>
                            <tr>               
                                <td class="summary" >
                                    摘要 
                                </td>
                            </tr>
                            <tr>               
                                <td class="clomns" >
                                    <input name="graphicsummary" id="graphicsummary" class="summary" type="text" style="width:88%;height: 18px;" /> 
                                </td>
                            </tr>
                            <tr class="rows">
                                <td class="clomns" >
                                    正文:
                                </td>
                            </tr>
                            <tr>
                                <td class="clomns" >
                                    <textarea  name="mainbody" id="mainbody" style="width: 87%" rows="6"></textarea> 
                                </td>
                            </tr>
                            <tr class="rows">
                                <td class="clomns" >
                                    <a href="#"  class="addSourceLink" onclick="showSourceLink()">添加原文链接</a>
                                </td>
                            </tr>
                            <tr class="rows">
                                <td class="sourceLink" >
                                    原文链接
                                </td>
                            </tr>
                            <tr>
                                <td class="sourceLink" >
                                    <input name="originalurl" id="originalurl" type="text" style="width:88%;height: 18px;"/> 
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div class="left_div">
                        <img id="coverImage" alt="封面图片" src=""  width="500" height="500"/>图片预览
                    </div>
                </div>
                <!-- 多图文 -->
                <div id="tb3">
                    <div class="moreright_div">
                        <!--图文1-->
                        <table id="testMessageGrid2">
                            <tr>
                                <td class="clomns" >
                                    标题：<input name="mpnewstitle1" id="mpnewstitle1" style="width:80%;height: 18px;"/>  
                                </td>
                            </tr>

                            <tr>
                                <td class="clomns">
                                    作者：<input name="mpnewsauthor1" id="mpnewsauthor1" style="width:80%;height: 18px;"/> 
                                </td>
                            </tr>

                            <tr class="rows">
                                <td class="clomns" >
                                    <form id="mpnewsFileFrom1" enctype="multipart/form-data" name="mpnewsFileFrom1">
                                        <input type="hidden" name="saveId1" id="saveId1" value=""/>
                                        封面：<input type='file' name='mpnewsFile1' id='mpnewsFile1' onchange="MultiMpnewsFileSelectEve(1)" style="width:81%;height: 18px;"/>
                                    </form>
                                </td>
                            </tr>
                            <tr class="rows">
                                <td  class="text1">
                                    <input type="checkbox" id="mpnewsifshow1" name="mpnewsifshow1" value="1" /> 封面显示在正文中
                                </td>
                            </tr>
                            <tr class="rows">
                                <td class="clomns" >
                                    正文
                                </td>
                            </tr>
                            <tr>
                                <td class="clomns" >
                                    <textarea  name="mpnewsmainbody1" id="mpnewsmainbody1" style="width: 87%" rows="6"></textarea> 
                                </td>
                            </tr>
                            <tr class="rows">
                                <td class="clomns" >
                                    <a href="#"  id="mpnewsAddSourceLink1"  onclick="showMoreSourceLink(1)">添加原文链接</a>
                                </td>
                            </tr>
                            <tr class="rows">
                                <td  class="mpnewsSourceLink" id='mpnewsSourceLink1' >
                                    原文链接
                                </td>
                            </tr>
                            <tr>
                                <td   >
                                    <input class="mpnewsSourceLink" name="mpnewsSrcurl1" id="mpnewsSrcurl1" type="text" style="width:88%;height: 18px;"/> 
                                </td>
                            </tr>
                        </table>
                    </div> 
                    <div class="moreleft_div">
                        <img id="coverImagemore1" alt="封面图片" src=""  />
                    </div>
                </div>
            </div>
        </div>
        <audio  src="" autoplay="autoplay" id="audo">您的浏览器不支持 audio 标签。</audio>
    </body>
    <script type="text/javascript">
        var imgRow;
        var voiceRow;
        var videoRow;
        var graphicRow;
        //start-->
        var author;
        var title;
        var content_source_url;
        var contents;
        var digest;
        var ifshowval;
        //end-->
        //获取文件路径start-->
        var projectName;
        var localhostPath;
        //获取文件路径end-->
        //多图文的个数
        var mulmpNum = 1;
        //多图文的数据包
        var mulmpdata = [];
        //单图文多图文标识
        var mpnewsTag = 0;
        //总体群发标识
        var sendallTag = 0;
        var K1;
        //富文本框初始化
        KindEditor.ready(function(K) {
            //   K1=K;
            //  window.editor = K.create('#txtArea');
            K1 = K.create('#txtArea', {
                uploadJson: "{:U('ConductFlowSheet/uploadImage')}",
                allowFileManager: false,
                height: '324px',
                afterCreate: function() {
                    this.sync();
                },
                afterBlur: function() {
                    this.sync();
                }, items: [
                    'fullscreen', 'undo', 'redo', 'cut', 'copy', 'paste',
                    'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                    'superscript', '|', 'selectall', '-',
                    'title', 'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold',
                    'italic', 'underline', 'strikethrough', 'removeformat', '|', 'image',
                    'flash', 'media', 'advtable'
                ]
            });
        });

        function SaveHtml() {
            var htmls = $("#txtArea").val();
            $.ajax({
                url: "{:U('Notic/saveListNotice')}",
                type: "POST",
                cache: true,
                dataType: "json",
                data: {htmlData: htmls, NoticeID: Id, title: $("#txtNoticTitle").val()},
                success: function(data) {
                    //   document.write(TreeDataStr);return;
                    if (data.error == '0') {
                        $("#hId").val(data.ID);
                        alert("保存成功!");
                        return;
                    }
                    else {
                        alert("保存失败!");
                        return;
                    }
                }
            });
        }

        function loadNoticData() {
            var param = {
            };
            $('#tbNoticGrid').datagrid({
                title: '问题列表',
                iconCls: 'icon-save',
                width: '80%',
                height: 'auto',
                nowrap: false,
                striped: true,
                url: "{:U('Notic/getListNotice')}",
                queryParams: param,
                columns: [[
                        {field: 'ID', hidden: true},
                        {field: 'Title', title: '标题', width: 400, align: 'left'},
                        {field: 'UpdateTime', title: '更新时间', width: 200, align: 'left'}
                    ]],
                toolbar: [{
                        id: 'btnadd',
                        text: '添加',
                        iconCls: 'icon-add',
                        handler: function() {
                            add();
                        }
                    }, '-', {
                        id: 'btncut',
                        text: '修改',
                        iconCls: 'icon-edit',
                        handler: function() {
                            edit();
                        }
                    }, '-', {
                        id: 'btnsave',
                        text: '删除',
                        iconCls: 'icon-remove',
                        handler: function() {
                            var rows = $('#tbNoticGrid').datagrid('getSelected');
                            if (rows == null || rows == undefined) {
                                alert("请选择需要删除的行");
                                return;
                            }
                            if (confirm("确定要删除该通知吗?")) {
                                del(rows);
                            }
                        }
                    }]
            });
        }
        ;

        function add() {
            $("#txtArea").val('');
            $("#txtNoticTitle").val('');
            Id = "";
            $("#tt").tabs("select", "新建列表通知");
        }
        var Id = "";
        function edit() {
            var rows = $('#tbNoticGrid').datagrid('getSelected');
            K1.html(rows.NoticHTMLContent);
            $("#txtNoticTitle").val(rows.Title);
            Id = rows.ID;
            $("#tt").tabs("select", "新建列表通知");
        }

        function del(rows) {
            $.post("{:U('Notic/deleteNotice')}", {NoticeID: rows.ID}, function(data) {
                if (data == 'y') {
                    $("#tbNoticGrid").datagrid("reload", {});
                }
                else {
                    alert("删除失败!");
                }
            });
        }

        $(function() {
            //获取项目路径
            var pathName = window.document.location.pathname;
            projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
            if (projectName == "/Home") {
                projectName = "/";
            } else {
                projectName = projectName + "/";
            }

            //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
            var curWwwPath = window.document.location.href;
            //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
            var pos = curWwwPath.indexOf(pathName);
            //获取主机地址，如： http://localhost:8083
            localhostPath = curWwwPath.substring(0, pos);
            //获取带"/"的项目名，如：/uimcardprj localhostPath + projectName
            $.ajax({
                url: "{:U('UserGroup/GetUserGroupAll')}",
                type: "POST",
                cache: true,
                dataType: "json",
                success: function(data) {
                    if (data[0].children != null && data[0].children != undefined) {
                        var GroupData = data[0].children;
                        $('#userGroup').combobox({
                            data: GroupData,
                            valueField: 'id',
                            textField: 'text'
                        });
                        $('#userGroup').combobox("select", GroupData[0].id);
                    }
                }
            });
            $(".tabs-title").click(function() {
                sendallTag = 0;
                if ($(this).html() == "文字") {
                }
                else if ($(this).html() == "图片") {
                    $("#imagePanel").window("open");
                    loadImageGrid();
                }
                else if ($(this).html() == "语音") {
                    $("#voicePanel").window("open");
                    loadVoiceGrid();
                }
                else if ($(this).html() == "视频") {
                    $("#videoPanel").window("open");
                    loadVideoGrid();
                }
                else if ($(this).html() == "图文消息") {
                    sendallTag = 1;
                    graphicDialog(false);
                    $("#graphicPanel").window("open");
                    loadGraphicGrid();
                }
                else if ($(this).html() == "单图文消息") {
                    $("#saveId").val(0);
                    changeDialog();
                    clickSingleMessage();
                }
                else if ($(this).html() == "多图文消息") {
                    changeMoreDialog();
                    clickMoreMessage();
                }
                else if ($(this).html() == "图文列表") {
                    graphicDialog(false);
                    goBack();
                    clearSingleMessage();
                    clearMultiMessage();
                    delImage();
                }
                else if ($(this).html() == "列表通知") {
                    loadNoticData();
                }
            });
            $("#btnSend").click(function() {
//                alert("sendallTag = " + sendallTag);
//                alert("mpnewsTag = " + mpnewsTag);

                var tab = $('#message').tabs('getSelected');
                var messageType = returnMessageType(tab.panel('options').title);
                if (sendallTag == 1 && mpnewsTag == 1) {
                    messageType = "mpnews";
                } else if (sendallTag == 1 && mpnewsTag == 2) {
                    messageType = "mulmpnews";
                }
                var sendType = $("#SendType").combobox("getValue");
                var messageText = $("#txtMessage").val();
                var groupId = $("#userGroup").combobox("getValue");
                var param = {};
                switch (messageType)
                {
                    case "text":
//                        alert("text");
                        param = {"messageType": messageType, "sendType": sendType, "message": messageText, "noticeID": "", "groupId": groupId};
                        break;
                    case "image":
//                        alert("image");
                        alert("正在发送图片");
                        param = {"messageType": messageType, "sendType": sendType, "message": imgRow.ImagePath, "noticeID": imgRow.ID, "groupId": groupId};
                        break;
                    case "voice":
//                        alert("voice");
                        alert("正在发送语音");
                        param = {"messageType": messageType, "sendType": sendType, "message": voiceRow.VoicePath, "noticeID": voiceRow.ID, "groupId": groupId};
                        break;
                    case "mpvideo":
//                        alert("mpvideo");
                        alert("正在发送视频");
                        param = {"messageType": messageType, "title": videoRow.Title, "description": videoRow.Description, "sendType": sendType, "message": videoRow.FilePath, "noticeID": videoRow.ID, "groupId": groupId};
                        break;
                        //单图文的测试通过
                    case "mpnews":
                        alert("正在发送单图文");
                        param = {"messageType": messageType, "sendType": sendType, "message": graphicRow.CoverPath, "noticeID": graphicRow.ID, "groupId": groupId,
                            "author": author, "title": title, "content_source_url": content_source_url, "contents": contents, "digest": digest, "show_cover_pic": ifshowval
                        };
                        break;
                        //多图文mulmpdata
                    case "mulmpnews":
//                        alert("mulmpnews");
                        alert("正在发送多图文");
                        param = {"messageType": "mulmpnews", "sendType": sendType, "message": mulmpdata, "noticeID": graphicRow.ID, "groupId": groupId};
                        break;
                }
                $.ajax({
                    url: "{:U('Notic/SentMessage')}",
                    type: "POST",
                    cache: true,
                    data: param,
                    success: function(data) {
//                        alert(data);
                        if (data == 'y') {
                            alert("发送成功!");
                        } else {
                            alert("发送失败,SUCCESS!");
                        }
                    },
                    error: function(data, status, e) {
                        alert("发送失败,ERROR:" + e);
                    }
                });
            });
            $('#imagePanel').dialog({
                title: '选择素材',
                width: 900,
                height: 500,
                closed: true,
                cache: false,
                resizable: true,
                modal: true,
                toolbar: '#tb',
                buttons: [{
                        text: '确定',
                        iconCls: 'icon-ok',
                        handler: function() {
                            var rows = $('#tbGrid').datagrid('getSelected');
                            imgRow = rows;
                            var img = '<img width="300px" hight="100px" src="' + projectName + rows.ImagePath + '" />';
                            $('#dimg').html(img);
                            $("#imagePanel").window("close");
                        }
                    }, {
                        text: '取消',
                        iconCls: 'icon-cancel',
                        handler: function() {
                            $("#imagePanel").window("close");
                        }
                    }]
            });
            $('#voicePanel').dialog({
                title: '选择素材',
                width: 900,
                height: 500,
                closed: true,
                cache: false,
                resizable: true,
                modal: true,
                toolbar: '#voiceTool',
                buttons: [{
                        text: '确定',
                        iconCls: 'icon-ok',
                        handler: function() {
                            var rows = $('#voiceGrid').datagrid('getSelected');
                            voiceRow = rows;
                            var d1 = '<div  onclick=playAudio(this)  class="" src="/' + projectName + rows.VoicePath + '>';
                            var d2 = '<div id="wxAudioBox"  class="audioBox">';
                            var d3 = '<div class="audioIconWrp">';
                            var d4 = '<span class="audioIcon" title="点击播放"></span>';
                            var d5 = '<span class="audioIconGif"></span>';
                            var d6 = '</div></div></div>';
                            var voice = d1 + d2 + d3 + d4 + d5 + d6;
                            $('#dvoice').html(voice);
                            $("#voicePanel").window("close");
                        }
                    }, {
                        text: '取消',
                        iconCls: 'icon-cancel',
                        handler: function() {
                            $("#voicePanel").window("close");
                        }
                    }]
            });
            graphicDialog(true);
            $('#videoPanel').dialog({
                title: '选择素材',
                width: 900,
                height: 500,
                closed: true,
                cache: false,
                resizable: true,
                modal: true,
                buttons: [{
                        text: '确定',
                        iconCls: 'icon-ok',
                        handler: function() {
                            var rows = $('#videoGrid').datagrid('getSelected');
                            videoRow = rows;
                            var video = '<video  autoplay="autoplay" height="200px"  controls="controls"><source  src="/' + rows.FilePath + '" type="video/mp4" /> </video>';
                            //  var   video =  '<video  src="http://video.store.qq.com/vweixinp.tc.qq.com/1007_a70eb791ed774ca68c5fee8af3b8ca74.f10.mp4?vkey=E71BDA31273486114E3CB3ABC7A82E52B58B30BD2474D824DE7EE02CD84AEE339CD35F08F7FB8F8A&sha=0" autoplay="autoplay" height="200px"  controls="controls"></video>';
                            $("#dvideo").html(video);
                            $("#videoPanel").window("close");
                        }
                    }, {
                        text: '取消',
                        iconCls: 'icon-cancel',
                        handler: function() {
                            $("#videoPanel").window("close");
                        }
                    }]
            });
            /**
             * 图文整体弹出框架
             */
//            $('#graphicPanel').dialog({
//                title: '选择素材',
//                width: 900,
//                height: 500,
//                closed: true,
//                cache: false,
//                resizable: true,
//                modal: true,
//                buttons: [{
//                        text: '确定',
//                        iconCls: 'icon-ok',
//                        handler: function() {
//                            var rows = $('#graphicGrid').datagrid('getSelected');
//                            graphicRow = rows;
//                            if (rows.GraphicType == 0) {
//                                //将图文标识定位单图文
//                                mpnewsTag = 1;
//                                //给发送的图文消息赋值start
//                                author = rows.GraphicAuthor;
//                                title = rows.GraphicTitle;
//                                content_source_url = rows.OriginalUrl;
//                                contents = rows.MainBody;
//                                digest = rows.Summary;
//                                ifshowval = rows.IfShow;
//                                //给发送的图文消息赋值end
//                                var graphic = "<div style='width:300px; text-align:center; border:1px solid #CCC;'>";
//                                graphic += "<div class='mpnews_bag'>";
//                                graphic += "<div class='mpnews_title'>" + rows.GraphicTitle + "</div>";
//                                graphic += "<br/>";
//                                graphic += "<div class='mulmps_time'>" + changeTimeType(rows.UploadTime) + "</div>";
//                                graphic += "<br/>";
//                                graphic += "<img width='280' height='170' src='" + projectName + rows.CoverPath + "'/><br/><br/>";
//                                graphic += "<div class='mulmps_content'>" + rows.MainBody.substring(0, 50) + "..." + "</div>";
//                                graphic += "</div>";
//                                graphic += "</div><br/>";
//                                $("#mpnews").html(graphic);
//                                $("#graphicPanel").window("close");
//                            } else if (rows.GraphicType == 1) {
//                                //将图文标识定位单图文
//                                mpnewsTag = 2;
//                                loadMpNews(rows.ParentId);
//                            }
//                        }
//                    }, {
//                        text: '取消',
//                        iconCls: 'icon-cancel',
//                        handler: function() {
//                            $("#graphicPanel").window("close");
//                            goBack();
//                        }
//                    }]
//            });
        });
        function playAudio(obj) {
            var cs = $(obj).attr("class");
            var src = $(obj).attr("src");
            if (cs == "") {
                $(obj).addClass("wxAudioPlaying");
                document.getElementById("audo").src = src;
                document.getElementById("audo").play();
            }
            else {
                $(obj).removeClass("wxAudioPlaying");
                document.getElementById("audo").pause();
            }
        }

        function loadImageGrid() {
            $('#tbGrid').datagrid({
                title: '图片列表',
                iconCls: 'icon-save',
                width: '100%',
                url: "{:U('Notic/getImageList')}",
                nowrap: false,
                striped: true,
                remoteSort: false,
                columns: [[
                        {field: 'ImageName', title: '', width: 200, align: 'left', formatter: function(value, row, index) {
                                return  '<a  href="javascript:void(0)" data-p1=' + index + ' class="easyui-tooltip" >' + row.ImageName + '</a>';
                            }},
                        {field: 'ImageSize', title: '', width: 200, formatter: function(value, row, index) {
                                return  row.ImageSize + "K";
                            }},
                        {field: 'UploadTime', title: '', width: 480, align: 'left'}
                    ]],
                onLoadSuccess: function(data) {
                    $('.easyui-tooltip').tooltip({position: 'right',
                        onShow: function() {
                            var index = parseInt($(this).attr('data-p1'));
                            var row = $('#tbGrid').datagrid('getRows')[index];
                            var img = '<img width="300px" hight="100px" src="/' + row.ImagePath + '" />';
                            $(this).tooltip('update', img);
                            $(this).tooltip('tip').css({backgroundColor: '#666', borderColor: '#666'});
                        }});
                }
            });
        }

        function loadVoiceGrid() {
            $('#voiceGrid').datagrid({
                title: '声音列表',
                iconCls: 'icon-save',
                width: '100%',
                url: "{:U('Notic/getVoiceList')}",
                nowrap: false,
                striped: true,
                remoteSort: false,
                columns: [[
                        {field: 'VoiceName', title: '', width: 200, align: 'left'},
                        {field: 'VoicePath', title: '', width: 100, align: 'left', formatter: function(value, row, index) {
                                var op1 = '<div  src=/' + row.VoicePath + ' onclick=playAudio(this) class="">';
                                var op2 = '<div id="wxAudioBox" class="audioBox">';
                                var op3 = '<div class="audioIconWrp">';
                                var op4 = '<span class="audioIcon" title="点击播放"></span>';
                                var op5 = '<span class="audioIconGif"></span></div></div></div>';
                                return op1 + op2 + op3 + op4 + op5;
                            }},
                        {field: 'VoiceSize', title: '', width: 200, formatter: function(value, row, index) {
                                return  row.VoiceSize + "K";
                            }},
                        {field: 'UploadTime', title: '', width: 360, align: 'left'}
                    ]]
            });
        }

        function loadVideoGrid() {
            $('#videoGrid').datagrid({
                title: '视频列表',
                iconCls: 'icon-save',
                width: '100%',
                url: "{:U('Notic/getVideoList')}",
                nowrap: false,
                striped: true,
                remoteSort: false,
                columns: [[
                        {field: 'Title', title: '标题', width: 200, align: 'left'},
                        {field: 'Description', title: '简介', width: 100, align: 'left'},
                        {field: 'FileName', title: '文件名称', width: 200, align: 'left'},
                        {field: 'UploadTime', title: '上传时间', width: 200, align: 'left'}
                    ]]
            });
        }
        function loadGraphicGrid() {
            $('#graphicGrid').datagrid({
                title: '图文列表',
                iconCls: 'icon-save',
                width: '100%',
                url: "{:U('Notic/getGraphicList')}",
                nowrap: false,
                striped: true,
                remoteSort: false,
                columns: [[
                        {field: 'GraphicTitle', title: '标题', width: 200, align: 'left'},
                        {field: 'GraphicAuthor', title: '作者', width: 100, align: 'left'},
                        {field: 'MainBody', title: '正文', width: 200, align: 'left', formatter: function(value, row, index) {
                                var cutBody = value.substring(0, 10) + "...";
                                return cutBody;
                            }},
                        {field: 'GraphicType', title: '图文类型', width: 150, align: 'left', formatter: function(value, row, index) {
                                return value == 0 ? "单图文" : "多图文";
                            }},
                        {field: 'UploadTime', title: '上传时间', width: 150, align: 'left'}
                    ]]
            });
        }

        function returnMessageType(title) {
            if (title == '文字')
                return "text";
            else if (title == '图片')
                return "image";
            else if (title == '语音')
                return "voice";
            else if (title == '视频')
                return "mpvideo";
            else if (title == '图文消息')
                return "mpnews";
        }

        function FileSelectEve(formObj, gridobj, fileType) {
            formObj.ajaxSubmit({
                success: function(data, textStatus) {
                    if (data == "y") {
                        gridobj.datagrid("reload", {});
                    }
                    else {
                        alert("上传失败,错误信息 SUCCESS:" + data);
                    }
                },
                error: function(data, status, e) {
                    alert("上传失败，错误信息 ERROR：" + e);
                },
                url: "{:U('Notic/UploadFile')}",
                type: "post",
                data: {fileType: fileType},
                timeout: 600000
            });
        }
        var FileName;
        function VideoFileSelectEve() {
            var file = $("#videoFile").val();
            $("#formVideo").ajaxSubmit({
                success: function(data, textStatus) {
                    if (data.error == "0") {
                        $("#saveId").val(data.saveId);
                        $("#txtUrl").val(file);
                    }
                    else {
                        alert("上传失败,错误信息:" + data.errstr);
                    }
                },
                error: function(data, status, e) {
                    alert("上传失败，错误信息：" + e);
                },
                url: "{:U('Notic/UploadFile')}",
                type: "post",
                dataType: "json",
                data: {fileType: "mpvideo"},
                timeout: 600000
            });
        }
        function VideoInfoSave() {
            var videoInfo = {
                title: $("#txtTitle").val(),
                description: $("#txtSummary").val(),
                id: $("#saveId").val()};
            $.post("{:U('Notic/UpdateVideoInfo')}", videoInfo, function(data, status, obj) {
                if (data == "y") {
                    $("#videoGrid").datagrid("reload", {});
                }
                else {
                    alert("保存失败!");
                }
            });
        }

        /**
         * 上传图文信息的封面图片
         * @returns {undefined}
         */
        function GraphicFileSelectEve() {
            var file = $("#graphicFile").val();
//            alert($("#saveId").val());
            if ($("#saveId").val() > 0) {
                var saveExistId = $("#saveId").val();
                $("#formGraphic").ajaxSubmit({
                    url: "{:U('Notic/UpdateFile')}",
                    type: "post",
                    dataType: "json",
                    data: {fileType: "mpnews", saveId: saveExistId, mpid: 0},
                    timeout: 600000,
                    success: function(data, textStatus) {
//                        alert(data.saveId);
                        if (data.error == "0") {
                            $("#saveId").val(data.saveId);
                            $("#coverImage").attr('src', localhostPath + projectName + data.imgpath);
                        }
                        else {
                            alert("上传失败,错误信息success::" + data.errstr);
                        }
                    },
                    error: function(data, status, e) {
                        alert("上传失败，错误信息error:：" + e);
                    }
                });
            } else {
                $("#formGraphic").ajaxSubmit({
                    url: "{:U('Notic/UploadFile')}",
                    type: "post",
                    dataType: "json",
                    data: {fileType: "mpnews"},
                    timeout: 600000,
                    success: function(data, textStatus) {
//                        alert(data.saveId);
                        if (data.error == "0") {
                            $("#saveId").val(data.saveId);
                            $("#coverImage").attr('src', localhostPath + projectName + data.imgpath);
                        }
                        else {
                            alert("上传失败,错误信息success::" + data.errstr);
                        }
                    },
                    error: function(data, status, e) {
//                        alert(data);
                        alert("上传失败，错误信息error:：" + e);
                    }
                });
            }
        }

        /**
         * 单图文保存
         * @returns {undefined}
         */
        function GraphicInfoSave() {
            //判断checkbox是否被选中
            if ($("#ifshow").attr("checked") == "checked") {
                ifshowval = 1;
            } else {
                ifshowval = 0;
            }
//            alert("准备保存到 = " + $("#saveId").val());
//            alert("graphictitle " + $("#graphictitle").val());
//            alert("graphicauthor " + $("#graphicauthor").val());
//            alert("mainbody " + $("#mainbody").val());
//            alert("saveId " + $("#saveId").val());
//            alert("ifshowval " + ifshowval);
//            alert("graphicsummary " + $("#graphicsummary").val());
//            alert("originalurl " + $("#originalurl").val());

            var graphicInf = {
                graphictitle: $("#graphictitle").val(),
                graphicauthor: $("#graphicauthor").val(),
                mainbody: $("#mainbody").val(),
                graphicid: $("#saveId").val(),
                ifshow: ifshowval,
                summary: $("#graphicsummary").val(),
                originalurl: $("#originalurl").val()
            };
            $.post("{:U('Notic/UpdateGraphicInfo')}", graphicInf, function(data, status, obj) {
//                alert(data);
                if (data == "y") {
                    alert("保存成功");
                    //$("#message1").tabs("select", 0);
                    goBack();
                    graphicDialog(false);
                    $("#graphicGrid").datagrid("reload", {});
                }
                else {
                    alert("保存失败!");
                }
            });
        }

        /**
         * 上传图文信息的封面图片
         * @returns {undefined}
         */
        function MultiMpnewsFileSelectEve(mpid) {
            var saveExistId = $("#saveId" + mpid).val();
//            alert(saveExistId);
//            var file = $("#mpnewsFile" + mpid).val();
            if (saveExistId > 0) {
//                alert("saveId");
                $("#mpnewsFileFrom" + mpid).ajaxSubmit({
                    url: "{:U('Notic/UpdateFile')}",
                    type: "post",
                    dataType: "json",
                    data: {fileType: "mulmpnews", saveId: saveExistId, mpid: mpid},
                    timeout: 600000,
                    success: function(data, textStatus) {
                        if (data.error == "0") {
                            $("#saveId" + mpid).val(data.saveId);
                            $("#coverImagemore" + mpid).attr('src', localhostPath + projectName + data.imgpath);
                        }
                        else {
                            alert("上传失败,错误信息success:" + data.errstr);
                        }
                    },
                    error: function(data, status, e) {
                        alert("上传失败，错误信息error：" + e);
                    }
                });
            } else {
                $("#mpnewsFileFrom" + mpid).ajaxSubmit({
                    url: "{:U('Notic/UploadFile')}",
                    type: "post",
                    dataType: "json",
                    data: {fileType: "mulmpnews", mpid: mpid},
                    timeout: 600000,
                    success: function(data, textStatus) {
                        if (data.error == "0") {
                            $("#saveId" + mpid).val(data.saveId);
                            $("#coverImagemore" + mpid).attr('src', localhostPath + projectName + data.imgpath);
                        }
                        else {
                            alert("上传失败,错误信息success:" + data.errstr);
                        }
                    },
                    error: function(data, status, e) {
                        alert("上传失败，错误信息error：" + e);
                    }
                });
            }
        }

        /**
         * 多图文保存
         * @returns {undefined}
         */
        function  MpnewsInfoSave() {
//            alert("mulmpNum = " + mulmpNum);
            var mpnewsList = [];
            for (var index = 1; index <= mulmpNum; index++) {
//                alert($("#mpnewstitle" + index).val());
//                alert($("#mpnewsauthor" + index).val());
//                alert($("#mpnewsmainbody" + index).val());
//                alert($("#saveId" + index).val());
//                alert($("#mpnewsSrcurl" + index).val());

                var graphicInf = {
                    graphictitle: $("#mpnewstitle" + index).val(),
                    graphicauthor: $("#mpnewsauthor" + index).val(),
                    mainbody: $("#mpnewsmainbody" + index).val(),
                    graphicid: $("#saveId" + index).val(),
                    ifshow: $("#mpnewsifshow" + index).attr("checked") == "checked" ? 1 : 0,
                    originalurl: $("#mpnewsSrcurl" + index).val(),
                    graphicorder: index
                };
                mpnewsList.push(graphicInf);
            }
            var mpnewsInfo = {
                mpnewsList: mpnewsList
            }
            $.post("{:U('Notic/UpdateMpNewsInfo')}", mpnewsInfo, function(data, status, obj) {
//                alert(data);
                if (data == "y") {
                    alert("保存成功");
                    graphicDialog(false);
                    goBack();
                    delImage();
                    $("#graphicGrid").datagrid("reload", {});
                }
                else {
                    alert("保存失败!");
                }
            });
        }

        /**
         * 获取某一条多图文的消息
         * @returns {undefined}
         */
        function loadMpNews(parentid) {
            var queryData = {
                parentid: parentid
            };
            $.ajax({
                url: "{:U('Notic/getMulMpList')}",
                type: "POST",
                cache: true,
                data: queryData,
                dataType: 'json',
                success: function(data) {
                    mulmpdata = [];
                    var graphic = "<table style='width:300px;text-align:center;border:1px solid #CCC;' border='0' cellpadding='0' cellspacing='0'>";
                    $.each(data, function(key, value) {

                        if (value.GraphicOrder == 1) {
                            graphic += "  <tr>";
                            graphic += "    <td><div class='mulmps_head'>";
                            graphic += "    <div class='mulmps_time'>" + changeTimeType(value.UploadTime) + "</div><br/>";
                            graphic += "        <div class='mulmps_head_img'><img height='160' width='280' src='" + projectName + value.CoverPath + "'  /></div>";
                            graphic += "        <div class='mulmps_head_txt'>" + value.GraphicTitle.substring(0, 25) + "</div>";
                            graphic += "      </div></td>";
                            graphic += "  </tr>";
                        } else {
                            graphic += "  <tr>";
                            graphic += "    <td class='mulmps_tr'><table class='mulmps_child' border='0' align='center' cellpadding='0' cellspacing='0'>";
                            graphic += "        <tr>";
                            graphic += "          <td><div class='mulmps_child_txt'>" + value.GraphicTitle.substring(0, 25) + "</div></td>";
                            graphic += "          <td align='right'><img src='" + projectName + value.CoverPath + "'  height='80' width='80'/></td>";
                            graphic += "        </tr>";
                            graphic += "      </table></td>";
                            graphic += "  </tr>";
                        }
                        var mplist = {
                            mpnewstitle: value.GraphicTitle,
                            mpnewsauthor: value.GraphicAuthor,
                            mpnewsifshow: value.IfShow,
                            mpnewsmainbody: value.MainBody,
                            mpnewsSrcurl: value.OriginalUrl,
                            mpnewsFile: value.CoverPath
                        }
                        mulmpdata.push(mplist);
                    });
                    graphic += "</table><br/><br/>";
                    //                    $('#mulmpdetail').html(graphic);
                    $("#mpnews").html(graphic);
                    $("#graphicPanel").window("close");
                },
                error: function(data, status, e) {
                    alert("发送失败,ERROR:" + e);
                }
            });
        }

        function changeTimeType(numTime) {
            var strTime = numTime.substring(0, 4) + "年";
            strTime += numTime.substring(5, 7) + "月";
            strTime += numTime.substring(8, 10) + "日";
            return strTime;
        }
    </script>
    <script>
        function graphicDialog(type) {
            $('#graphicPanel').dialog({
                title: '选择素材',
                width: 900,
                height: 500,
                closed: type,
                cache: false,
                resizable: true,
                modal: true,
                buttons: [{
                        text: '确定',
                        iconCls: 'icon-ok',
                        handler: function() {
                            var rows = $('#graphicGrid').datagrid('getSelected');
                            graphicRow = rows;
                            if (rows.GraphicType == 0) {
                                //将图文标识定位单图文
                                mpnewsTag = 1;
                                //给发送的图文消息赋值start
                                author = rows.GraphicAuthor;
                                title = rows.GraphicTitle;
                                content_source_url = rows.OriginalUrl;
                                contents = rows.MainBody;
                                digest = rows.Summary;
                                ifshowval = rows.IfShow;
                                //给发送的图文消息赋值end
                                var graphic = "<div style='width:300px; text-align:center; border:1px solid #CCC;'>";
                                graphic += "<div class='mpnews_bag'>";
                                graphic += "<div class='mpnews_title'>" + rows.GraphicTitle + "</div>";
                                graphic += "<br/>";
                                graphic += "<div class='mulmps_time'>" + changeTimeType(rows.UploadTime) + "</div>";
                                graphic += "<br/>";
                                graphic += "<img width='280' height='170' src='" + projectName + rows.CoverPath + "'/><br/><br/>";
                                graphic += "<div class='mulmps_content'>" + rows.MainBody.substring(0, 50) + "..." + "</div>";
                                graphic += "</div>";
                                graphic += "</div><br/>";
                                $("#mpnews").html(graphic);
                                $("#graphicPanel").window("close");
                            } else if (rows.GraphicType == 1) {
                                //将图文标识定位单图文
                                mpnewsTag = 2;
                                loadMpNews(rows.ParentId);
                            }
                        }
                    }, {
                        text: '取消',
                        iconCls: 'icon-cancel',
                        handler: function() {
                            $("#graphicPanel").window("close");
                            goBack();
                        }
                    }
                    , {text: '编辑',
                        iconCls: 'icon-edit',
                        handler: function() {
                            var grpidselect = $('#graphicGrid').datagrid('getSelected');
                            var changeType = grpidselect.GraphicType;
                            if (0 == changeType) {
                                changeDialog();
                                clickSingleMessage();
                                if (grpidselect.IfShow == 1) {
                                    $("#ifshow").attr("checked", true);
                                } else {
                                    $("#ifshow").attr("checked", false);
                                }
//                                $("#graphicFile").hide();
                                $("#saveId").val(grpidselect.ID);
                                $("#graphicauthor").val(grpidselect.GraphicAuthor);
                                $("#graphictitle").val(grpidselect.GraphicTitle);
                                $("#mainbody").val(grpidselect.MainBody);
                                $("#originalurl").val(grpidselect.OriginalUrl);
                                $("#graphicsummary").val(grpidselect.Summary);
                                $("#coverImage").attr('src', localhostPath + projectName + grpidselect.CoverPath);
                                $("#message1").tabs("select", "单图文消息");
                            } else if (1 == changeType) {
                                var parentId = $('#graphicGrid').datagrid('getSelected').ParentId;
                                var queryData = {
                                    parentid: parentId
                                }
                                $.ajax({
                                    url: "{:U('Notic/getMulMpList')}",
                                    type: "POST",
                                    cache: true,
                                    data: queryData,
                                    dataType: 'json',
                                    success: function(data) {
                                        for (var aa = 0; aa < data.length - 1; aa++) {
                                            changeMoreDialog();
                                            clickMoreMessage();
                                            $("#message1").tabs("select", "多图文消息");
                                            addImage();
                                        }
                                        var i;
                                        for (i = 0; i < data.length; i++) {
                                            if (data[i].IfShow == 1) {
                                                $("#mpnewsifshow" + (i + 1)).attr("checked", true);
                                            } else {
                                                $("#mpnewsifshow" + (i + 1)).attr("checked", false);
                                            }
                                            $("#mpnewstitle" + (i + 1)).val(data[i].GraphicTitle);
                                            $("#mpnewsauthor" + (i + 1)).val(data[i].GraphicAuthor);
                                            $("#mpnewsmainbody" + (i + 1)).val(data[i].MainBody);
                                            $("#mpnewsSrcurl" + (i + 1)).val(data[i].OriginalUrl);
                                            $("#saveId" + (i + 1)).val(data[i].ID);
                                            $("#coverImagemore" + (i + 1)).attr('src', localhostPath + projectName + data[i].CoverPath);
                                        }
//                                        mulmpNum = i;
                                    }
                                });
                            }
                        }
                    }
                ]
            });
        }
        function changeDialog() {
            $('#graphicPanel').dialog({
                title: '选择素材',
                width: 900,
                height: 500,
                closed: false,
                cache: false,
                resizable: true,
                modal: true,
                buttons: [{
                        text: '保存',
                        iconCls: 'icon-save',
                        handler: function() {
                            GraphicInfoSave();
                        }
                    }]
            });
        }

        function changeMoreDialog() {
            $('#graphicPanel').dialog({
                title: '选择素材',
                width: 900,
                height: 500,
                closed: false,
                cache: false,
                resizable: true,
                modal: true,
                buttons: [{
                        text: '添加',
                        iconCls: 'icon-save',
                        handler: function() {
                            addImage();
                        }
                    }, {
                        text: '保存',
                        iconCls: 'icon-save',
                        handler: function() {
                            MpnewsInfoSave();
                        }
                    }]
            });
        }

        function clearSingleMessage() {
            $("#graphicauthor").val(null);
            $("#graphictitle").val(null);
            $("#mainbody").val(null);
            $("#originalurl").val(null);
            $("#graphicsummary").val(null);
            $("#coverImage").attr('src', null);
            //clickMoreMessage();
        }
        function clearMultiMessage() {
            var clearnum;
            for (clearnum = 0; clearnum < 8; clearnum++) {
                $("#mpnewstitle" + (clearnum + 1)).val(null);
                $("#mpnewsauthor" + (clearnum + 1)).val(null);
                $("#mpnewsmainbody" + (clearnum + 1)).val(null);
                $("#mpnewsSrcurl" + (clearnum + 1)).val(null);
                $("#saveId" + (clearnum + 1)).val(null);
                $("#coverImagemore" + (clearnum + 1)).attr('src', null);
            }
        }

        function delImage() {
            for (var key = 0; key < 8; key++) {
                $("#div1").remove();
                $("#div").remove();
                mulmpNum = 1;
            }
        }

        function clickSingleMessage() {
            $("#tb1").css("display", "none");
            $("#tb2").css("display", "block");
            $("#tb3").css("display", "none");
            //$("#bgcolor").css("display", "block");
            $("#backMessage").css("color", "#000000");
            $("#singleMessage").css("color", "#ccc");
            $("#moreMessage").css("color", "#000000");
        }
        function goBack() {
            $("#message1").tabs("select", "图文列表");
            $('#graphicGrid').datagrid("reload", {});
            $("#tb1").css("display", "block");
            $("#tb2").css("display", "none");
            $("#tb3").css("display", "none");
            //$("#bgcolor").css("display", "none");
            $("#backMessage").css("color", "#ccc");
            $("#singleMessage").css("color", "#000000");
            $("#moreMessage").css("color", "#000000");
        }
        function clickMoreMessage() {
            $(".dialog-button").show();
            $("#tb1").css("display", "none");
            $("#tb3").css("display", "block");
            $("#tb2").css("display", "none");
            //$("#bgcolor").css("display", "block");
            $("#backMessage").css("color", "#000000");
            $("#singleMessage").css("color", "#000000");
            $("#moreMessage").css("color", "#ccc");
        }
        function showSummary() {
            $(".summary").css("display", "block");
            $(".addSummary").css("display", "none");
        }
        function showMoreSourceLink(mpid) {
            $("#mpnewsSourceLink" + mpid).css("display", "block");
            $("#mpnewsAddSourceLink" + mpid).css("display", "none");
            $("#mpnewsSrcurl" + mpid).css("display", "block");
        }
        function showSourceLink() {
            $(".sourceLink").css("display", "block");
            $(".addSourceLink").css("display", "none");
        }
        function addImage() {
//            alert(mulmpNum++);
            if (mulmpNum > 7) {
                alert("微信说最多只能加8条单图文，我也没办法，对不住了！");
                return false;
            }
            mulmpNum++;
            var div = document.createElement("div");//获取标签
            div.id = "div";
            div.className = "divstyle";
            div.style.display = "block";
            div.style.width = "99%";
            div.style.height = "280px";
            div.style.zIndex = "101";
            div.innerHTML = "<img class='imagemore' id='coverImagemore" + mulmpNum + "' src='' alt='图片显示' />";
            $(".moreleft_div").append(div);

            var div1 = document.createElement("div");//获取标签
            div1.id = "div1";
            div1.className = "divstyle";
            div1.style.display = "block";
            div1.style.width = "99%";
            div1.style.height = "280px";
            div1.style.zIndex = "101";
            div1.innerHTML = "<table class='extendTable' id='testMessageGrid2'>\n\
<tr><td class='clomns'>标题：<input name='mpnewstitle" + mulmpNum + "' id='mpnewstitle" + mulmpNum + "' style='width:80%;height: 18px;'/></td></tr>\n\
<tr><td class='clomns'>作者：<input name='mpnewsauthor" + mulmpNum + "' id='mpnewsauthor" + mulmpNum + "' style='width:80%;height: 18px;'/> </td></tr>\n\
<tr class='rows'><td class='clomns' ><form id='mpnewsFileFrom" + mulmpNum + "' name='mpnewsFileFrom" + mulmpNum + "'>\n\
<input type='hidden' name='saveId" + mulmpNum + "' id='saveId" + mulmpNum + "' value=''/>\n\
封面：<input type='file' name='mpnewsFile" + mulmpNum + "' id='mpnewsFile" + mulmpNum + "' onchange='MultiMpnewsFileSelectEve(" + mulmpNum + ")' style='width:81%;height: 18px;'/></form></td></tr>\n\
<tr class='rows'><td  class='text1'><input type='checkbox' id='mpnewsifshow" + mulmpNum + "' name='mpnewsifshow" + mulmpNum + "' value='1' /> 封面显示在正文中</td></tr>\n\
<tr><td class='clomns' ><input name='graphicsummarymore' id='graphicsummarymore' class='summary' type='text' style='width:88%;height: 18px;' /> </td></tr>\n\
<tr class='rows'><td class='clomns'>正文</td></tr>\n\
<tr><td class='clomns' >\n\
<textarea  name='mpnewsmainbody" + mulmpNum + "' id='mpnewsmainbody" + mulmpNum + "' style='width: 87%' rows='6'></textarea> </td></tr>\n\
<tr class='rows'><td class='clomns' ><a href='#' id='mpnewsAddSourceLink" + mulmpNum + "'   onclick='showMoreSourceLink(" + mulmpNum + ")'>添加原文链接</a></td></tr>\n\
<tr class='rows'>\n\
<td class='mpnewsSourceLink' id='mpnewsSourceLink" + mulmpNum + "' >原文链接</td></tr><tr><td  ><input class='mpnewsSourceLink' name='mpnewsSrcurl" + mulmpNum + "' id='mpnewsSrcurl" + mulmpNum + "' type='text' style='width:88%;height: 18px;'/> </td></tr></table>";
            $(".moreright_div").append(div1);
        }
        function showImage() {
            var file = $("#graphicFile").val();
            var img = $("#coverImage");
            img.src = file;
        }
    </script>
    <input type="hidden" id="saveId">
</html>
